//导入 createSlice
import {createSlice} from '@reduxjs/toolkit';

//定义 count 状态值的类型
interface CountType{
  value: number;
}

//定义状态的初始值
let initialState: CountType = {
  value: 100
}

//创建slice对象
let countSlice = createSlice({
  name: 'count',
  initialState: initialState,
  reducers: {
    incre: (state, action) => {
      state.value += action.payload
    },
    decre: (state, action) => {
      state.value -= action.payload;
    }
  }
});

//暴露
export let {incre, decre} = countSlice.actions;

export default countSlice.reducer;